<?php

class RegisterForm extends CFormModel
{
	public $username;
	public $password;
	public $password_repeat;
	public $email;
	public $sex;
	public $birthday;
	public $verifyCode;
	
	const SEX_MALE = 0;
	const SEX_FEMALE = 1;
	

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('username, password, email, birthday, password_repeat', 'required'),
			array('username', 'length', 'max'=>16),
			array('password', 'length', 'max'=>128),
			array('email', 'length', 'max'=>60),
			//email must be a email address
			array('email','email'),
			//password_repeat must repeat password exactly
			array('password_repeat', 'compare', 'compareAttribute'=>'password'),
		);
	}


	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'verifyCode'=>'Verification Code',
		);
	}

	
	/**
	 * @return array sex type names indexed by type IDs
	 */
	public function getSexOptions()
	{
		return array(
				self::SEX_MALE=>'male',
				self::SEX_FEMALE=>'female',
		);
		
	}
	
	/**
	 * @return string the sex text display for the current issue
	 */ 
	public function getSexText()
	{
		$typeOptions=$this->typeOptions;
		return isset($typeOptions[$this->type_id]) ? $typeOptions[$this->type_id] : "unknown type ({$this->type_id})";
	}
}